package kdtree;

import kdtree.KdTree.ResultHeap;


//128: 200ms
public class SequenceSearch {
	 static double[][]dict ;
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		int persize=128;
		dict=GenerateDataUtil.generate(100000, persize);
		double threshold=18f;
		long time=System.nanoTime();
		ResultHeap<String> topNHeap=find(GenerateDataUtil.generate(persize), threshold,1000);
		System.err.println("search time:"+(System.nanoTime()-time)/1000000);
		System.err.println(topNHeap.getList());
	}

	private static ResultHeap<String> find(double[] generate, double threshold, int topk) {
		ResultHeap<String> topNHeap=new ResultHeap<String>(topk);
		//BinaryFunctor<float[], float[], Float> metric=new EuclideanDistanceFunctor();
		System.out.println(dict.length);
		for(int i=0;i<dict.length;i++){
			
			double distance=GenerateDataUtil.pointDist(generate, dict[i]);
			//if(distance<=threshold){
				topNHeap.addValue(distance,null);
			//}
		}
		return topNHeap;
	}

}
